home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / misc / 655 / gem_show / gemshow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-26  |  1.5 KB  |  93 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <tos.h>
  5. #include <aes.h>
  6. #include <mint\mintbind.h>
  7.  
  8.  
  9. long    *cookies;
  10.  
  11.  
  12.  
  13. long get_cookiejar(void)
  14. {
  15.     long    **_cookiejar = (long **)0x5A0;
  16.     int          used;
  17.     
  18.     if (*_cookiejar == NULL)
  19.       return(0L);
  20.  
  21.     cookies = *_cookiejar;
  22.     for (used = 0; cookies[2*used] != 0L; used++)
  23.         if (cookies[2*used] == 0x4d694e54L)
  24.             break;
  25.     if (cookies[2*used] == 0L)
  26.         return(0L);
  27.     return(1L);
  28. }
  29.  
  30.  
  31.  
  32. main(int argc, char *argv[])
  33. {
  34.     char    buff[BUFSIZ], *s;
  35.     int        used, appl,
  36.             msg[208];
  37.     
  38.     if (argc > 1)
  39.     {
  40.         strcpy(buff, "");
  41.         for (used = 1; used < argc; used++)
  42.         {
  43.             strcat(buff, " ");
  44.             strcat(buff, argv[used]);
  45.         }
  46.     }
  47.     else
  48.     {
  49.         shel_read((char*)msg, &buff[1]);
  50.     }
  51.     buff[0] = (char)strlen(buff+1);
  52.  
  53.     if (Supexec(get_cookiejar) == 0L)
  54.     {
  55.         appl = appl_init();
  56.         used = appl_find("GEMVIEW ");
  57.         if (used >= 0)
  58.         {
  59.             strcpy((char*)&msg[8], buff+1);
  60.             msg[0] = 0xDF00;
  61.             msg[1] = appl;
  62.             msg[2] = (int)strlen(buff+1);
  63.             msg[3] = 0x0000;
  64.             appl_write(used, 16+msg[2], msg);
  65.         }
  66.         appl_exit();
  67.     }
  68.     else
  69.     {
  70.         appl = appl_init();
  71.         used = appl_find("GEMVIEW ");
  72.         if (used >= 0)
  73.         {
  74.             strcpy((char*)&msg[8], buff+1);
  75.             msg[0] = 0xDF00;
  76.             msg[1] = appl;
  77.             msg[2] = (int)strlen(buff+1);
  78.             msg[3] = 0x0000;
  79.             appl_write(used, 16+msg[2], msg);
  80.         }
  81.         else
  82.         {
  83.             appl_exit();
  84.             if ((s = getenv("GEMVIEW")) == NULL)
  85.               s = "C:\\GEMVIEW.APP";
  86.             if((int)Pexec(100, s, buff, NULL) < 0)
  87.                 return(-1);
  88.         }
  89.         appl_exit();
  90.     }
  91.     return(0);
  92. }
  93.